<?php

/**
 * This is the model class for table "cierre".
 *
 * The followings are the available columns in table 'cierre':
 * @property integer $id
 * @property string $code
 * @property string $date
 * @property string $director
 * @property string $secretaria
 * @property string $carrera
 * @property string $acta
 * @property string $inciso
 * @property string $subinciso
 * @property string $punto
 * @property integer $cerrado
 */
class cierre extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return cierre the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'cierre';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('cerrado', 'numerical', 'integerOnly'=>true),
			array('code', 'length', 'max'=>30),
			array('date', 'length', 'max'=>50),
			array('carrera', 'length', 'max'=>300),
                        array('director, secretaria', 'length', 'max'=>120),
			array('acta, inciso, subinciso, punto', 'length', 'max'=>20),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, code, date, carrera, acta, inciso, subinciso, punto', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
                    'estudiantes'=>array(self::HAS_MANY,'cierre_estudiante','id_code'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'Id',
			'code' => 'Code',
			'date' => 'Fecha Ingreso',
			'carnet' => 'Carnet',
			'carrera' => 'Carrera',
			'acta' => 'Acta',
			'inciso' => 'Inciso',
			'subinciso' => 'Subinciso',
			'punto' => 'Punto',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);

		$criteria->compare('code',$this->code,true);

		$criteria->compare('date',$this->date,true);

		$criteria->compare('carrera',$this->carrera,true);

		$criteria->compare('acta',$this->acta,true);

		$criteria->compare('inciso',$this->inciso,true);

		$criteria->compare('subinciso',$this->subinciso,true);

		$criteria->compare('punto',$this->punto,true);

		return new CActiveDataProvider('cierre', array(
			'criteria'=>$criteria,
		));
	}
}